package com.biz.primus.ms.depot.dao.repository;


import com.biz.primus.model.depot.vo.DepotQueryReqVo;
import com.biz.primus.ms.base.jpa.repository.CommonJpaRepositoryBean;
import com.biz.primus.ms.depot.dao.po.Depot;
import com.biz.primus.ms.depot.dao.specfication.DepotSpecification;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import javax.persistence.EntityManager;

/**
 * @author zhangcheng
 * @date 2016/12/12
 * @reviewer
 * @see
 */
public class DepotRepositoryImpl extends CommonJpaRepositoryBean<Depot, Long> implements DepotDao {

    @Autowired
    public DepotRepositoryImpl(EntityManager em) {
        super(Depot.class, em);
    }

    @Override
    public Page<Depot> searchDepots(final DepotQueryReqVo vo, final Pageable pageable) {
        if (vo == null) {
            return this.findAll(pageable);
        }
        return this.findAll(new DepotSpecification(vo), pageable);
    }
}
